#include <iostream>
#include <vector>
using namespace std;

class seg_tree {
	inline int L(int i)
	{
		return i << 1;
	}
	inline int R(int i)
	{
		return i << 1 | 1;
	}

	vector<int> isum;
	vector<int> iset;
	vector<bool> isupdate;

	void lazy(int i, int v, int n)
	{
		isum[i] = v * n;
		iset[i] = v;
		isupdate[i] = true;
	}

	void up(int i)
	{
		isum[i] = isum[L(i)] + isum[R(i)];
	}

	void down(int i, int ln, int rn)
	{
		if (isupdate[i]) {
			lazy(L(i), iset[i], ln);
			lazy(R(i), iset[i], rn);
			isupdate[i] = false;
		}
	}

    public:
	static int size;
	void update(int jobl, int jobr, int v, int l = 1, int r = size, int i = 1)
	{
		if (jobl <= l && r <= jobr) {
			lazy(i, v, r - l + 1);
			return;
		}

		int mid = (l + r) >> 1;
		down(i, mid - l + 1, r - mid);

		if (jobl <= mid) {
			update(jobl, jobr, v, l, mid, L(i));
		}
		if (mid < jobr) {
			update(jobl, jobr, v, mid + 1, r, R(i));
		}

		up(i);
	}

	int query(int jobl, int jobr, int l = 1, int r = size, int i = 1)
	{
		if (jobl <= l && r <= jobr) {
			return isum[i];
		}

		int sum = 0;
		int mid = (l + r) >> 1;
                down(i, mid -l + 1, r - mid);

		if (jobl <= mid) {
			sum += query(jobl, jobr, l, mid, L(i));
		}
		if (mid < jobr) {
			sum += query(jobl, jobr, mid + 1, r, R(i));
		}
		return sum;
	}

	int findkzero(int l, int r, int k)
	{
		if (l == r) {
			return l;
		}

		int mid = (l + r) >> 1;
		int zeros = mid - l + 1 - query(l, mid);
		if (zeros >= k) {
			return findkzero(l, mid, k);
		} else {
			return findkzero(mid + 1, r, k - zeros);
		}
	}

	seg_tree(int n) : isum(n << 2, 0), iset(n << 2, 0), isupdate(n << 2, false)
	{
		size = n;
	}
};
int seg_tree::size = 0;

pair<int, int> insert(seg_tree &sgt, int from, int flowers)
{
	int zeros = seg_tree::size - from + 1 - sgt.query(from, seg_tree::size);
	if (zeros == 0) {
		return { -1, -1 };
	}

	int start = sgt.findkzero(from, seg_tree::size, 1);
	int end = sgt.findkzero(from, seg_tree::size, min(zeros, flowers));
        sgt.update(start, end, 1);
	return { --start, --end };
}

void run()
{
	int n, m;
	cin >> n >> m;
	seg_tree sgt(n);

	for (int i = 0, op, l, r, f; i < m; i++) {
		cin >> op;
		if (op == 1) {
			cin >> l >> f;
                        ++l;
			auto pos = insert(sgt, l, f);
			if (pos.first == -1) {
				cout << "Can not put any one." << endl;
                                continue;
			}
			cout << pos.first << " " << pos.second << endl;
		} else {
			cin >> l >> r;
                        ++l;
                        ++r;
                        cout << sgt.query(l, r) << endl;
                        sgt.update(l, r, 0);
		}
	}
}

int main()
{
	int t;
	cin >> t;
	while (t--) {
		run();
	}
	return 0;
}
/*
1
10 5
1 3 5
2 4 5
1 1 8
2 3 6
1 8 8
*/